package com.fxc.handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;

@Controller
public class TextTemplateHandler {

    @Autowired
    private ServletContext servletContext;

    @RequestMapping("/test/thymeleaf")
    public String testThymeleaf(ModelMap modelMap, HttpSession session){

        // 1.将测试数据存入请求域
        modelMap.addAttribute("attrRequestScope", "attrRequestScope");

        // 2.将测试数据存入会话域
        session.setAttribute("attrNameSessionScope","attrNameSessionScope");

        // 3.将测试数据存入应用域
        servletContext.setAttribute("attrNameAppScope","attrNameAppScope");
        return "hello";
    }
}
